#include "RingQueue.hpp"

void * Consumer(void* arg)
{
  RingQueue<int>* rq = (RingQueue<int>*)arg;
  while(1){
    sleep(1);
    int data = 0;
    rq->Pop(data);
    cout<<"Consumer <<<< " << data <<endl;
  }
}

void* Producer(void* arg)
{
  RingQueue<int>*  rq = (RingQueue<int>*)arg;
  while(1){
    int data = rand()%100 + 1;
    rq->Push(data);//
    cout<<"Producer >>>> " << data << endl;
  }
}

int main()
{
  srand((unsigned long)time(nullptr));
  RingQueue<int> *rq = new RingQueue<int>();

  pthread_t c, p;
  pthread_create(&c, nullptr, Consumer, rq);
  pthread_create(&c, nullptr, Producer, rq);

  pthread_join(c, nullptr);
  pthread_join(p, nullptr);

  return 0;

}
